﻿using FDFtpSync.Core;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;

namespace FDFtpSync.Ioc
{
    public class DefaultRegOptions : IRegOptions
    {
        private IServiceCollection _services;

        public DefaultRegOptions(IServiceCollection services)
        {
            _services = services;
        }

        public IRegOptions AddScoped<TIn, TImpl>()
            where TIn : class
            where TImpl : class, TIn
        {
            _services.AddScoped<TIn, TImpl>();
            return this;
        }

        public IRegOptions AddScoped(Type interType, Type implType)
        {
            _services.AddScoped(interType, implType);
            return this;
        }

        public IRegOptions AddSingleton<TIn, TImpl>()
            where TIn : class
            where TImpl : class, TIn
        {
            _services.AddSingleton<TIn, TImpl>();
            return this;
        }

        public IRegOptions AddSingleton(object obj)
        {
            _services.AddSingleton(obj);
            return this;
        }

        public IRegOptions AddTransient<TIn, TImpl>()
            where TIn : class
            where TImpl : class, TIn
        {
            _services.AddTransient<TIn, TImpl>();
            return this;
        }

        public IRegOptions AddTransient(Type interType, Type implType)
        {
            _services.AddTransient(interType, implType);
            return this;
        }
    }
}
